package com.leo.foodmaster.admin.system.mapper;

import com.leo.foodmaster.admin.system.entity.UserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户和角色关联表 Mapper 接口
 * </p>
 *
 * @author Leo
 * @since 2021-06-18
 */
public interface UserRoleMapper extends BaseMapper<UserRole> {

    /**
     * 根据用户Id查询角色Ids
     * @param userId 用户Id
     * @return List<Long>
     */
    @Select("SELECT role_id " +
            "FROM sys_user_role " +
            "WHERE user_id = #{userId} ")
    List<Long> getRoleIdsByUserId(Long userId);
}
